﻿/*
 * User: DAvid
 * Date: 29/06/2013
 * Time: 12:38 AM
 * 
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using HockeySimulator.Entities.League;

namespace HockeySimulator
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainWindow : Form
	{
		private DebugWindow debugWindow;
		
		private League CurrentLeague;
		
		public MainWindow()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
			debugWindow = new DebugWindow();
			CurrentLeague = new League();
			
			debugWindow.AddDebugText(Environment.NewLine + CurrentLeague.Export(), true);
		}
		
		void DivsionsTabsDrawItem(object sender, DrawItemEventArgs e)
		{
			Graphics g = e.Graphics;
		    Brush _textBrush;
		
		    // Get the item from the collection.
		    TabPage _tabPage = (sender as TabControl).TabPages[e.Index];
		
		    // Get the real bounds for the tab rectangle.
		    Rectangle _tabBounds = (sender as TabControl).GetTabRect(e.Index);
		
		    if (e.State == DrawItemState.Selected)
		    {
		        // Draw a different background color, and don't paint a focus rectangle.
		        _textBrush = new SolidBrush(Color.Black);
		        g.FillRectangle(SystemBrushes.Control, e.Bounds);
		    }
		    else
		    {
		        _textBrush = new System.Drawing.SolidBrush(Color.Gray);
		        g.FillRectangle(SystemBrushes.ControlLight, e.Bounds);
		        //e.DrawBackground();
		    }
		
		    // Use Default font.
		    Font _tabFont = SystemFonts.DefaultFont;//new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel);
		
		    // Draw string. Center the text.
		    StringFormat _stringFlags = new StringFormat();
		    _stringFlags.Alignment = StringAlignment.Center;
		    _stringFlags.LineAlignment = StringAlignment.Center;
		    g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
		}
		
		void Btn_Temp1Click(object sender, EventArgs e)
		{
			League L = new League(true);
			
			debugWindow.AddDebugText(Environment.NewLine + L.Export());
		}
		
		void TabControl2DrawItem(object sender, DrawItemEventArgs e)
		{
			DivsionsTabsDrawItem(sender, e);
		}
	}
}
